home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
gnu
/
gas
/
gassrc02.zoo
/
read.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-27
|
56KB
|
2,104 lines
/* read.c - read a source file -
Copyright (C) 1986,1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
change this a bit. But then, GNU isn't
spozed to run on your machine anyway.
(RMS is so shortsighted sometimes.)
*/
#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
/* This is the largest known floating point */
/* format (for now). It will grow when we */
/* do 4361 style flonums. */
/* Routines that read assembler source text to build spagetti in memory. */
/* Another group of these functions is in the as-expr.c module */
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "as.h"
#include "read.h"
#include "md.h"
#include "hash.h"
#include "obstack.h"
#include "frags.h"
#include "flonum.h"
#include "struc-symbol.h"
#include "expr.h"
#include "symbols.h"
#ifdef SPARC
#include "sparc.h"
#define OTHER_ALIGN
#endif
#ifdef I860
#include "i860.h"
#endif
char * input_line_pointer; /* -> next char of source file to parse. */
#if BITS_PER_CHAR != 8
The following table is indexed by [ (char) ] and will break if
a char does not have exactly 256 states (hopefully 0:255!) !
#endif
const char /* used by is_... macros. our ctype[] */
lex_type [256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/*
* In: a character.
* Out: TRUE if this character ends a line.
*/
#define _ (0)
const char is_end_of_line [256] = {
_, _, _, _, _, _, _, _, _, _,99, _, _, _, _, _, /* @abcdefghijklmno */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, /* 0123456789:;<=>? */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */
_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */
};
#undef _
/* Functions private to this file. */
void equals();
void big_cons();
void cons();
static char* demand_copy_C_string();
static char* demand_copy_string();
void demand_empty_rest_of_line();
void float_cons();
long int get_absolute_expression();
static char get_absolute_expression_and_terminator();
static segT get_known_segmented_expression();
void ignore_rest_of_line();
static int is_it_end_of_statement();
static void pobegin();
static void pseudo_set();
static void stab();
static void stringer();
extern char line_comment_chars[];
static char * buffer_limit; /* -> 1 + last char in buffer. */
static char * bignum_low; /* Lowest char of bignum. */
static char * bignum_limit; /* 1st illegal address of bignum. */
static char * bignum_high; /* Highest char of bignum. */
/* May point to (bignum_start-1). */
/* Never >= bignum_limit. */
static char *old_buffer = 0; /* JF a hack */
static char *old_input;
static char *old_limit;
#ifndef WORKING_DOT_WORD
struct broken_word *broken_words;
int new_broken_words = 0;
#endif
static void grow_bignum ();
static int next_char_of_string ();
void
read_begin()
{
pobegin();
obstack_begin( ¬es, 5000 );
#define BIGNUM_BEGIN_SIZE (16)
bignum_low = xmalloc((long)BIGNUM_BEGIN_SIZE);
bignum_limit = bignum_low + BIGNUM_BEGIN_SIZE;
}
/* set up pseudo-op tables */
static struct hash_control *
po_hash = NULL; /* use before set up: NULL-> address error */
void s_abort(), s_align(), s_comm(), s_data();
void s_desc(), s_even(), s_file(), s_fill();
void s_globl(), s_lcomm(), s_line(), s_lsym();
void s_org(), s_set(), s_space(), s_text();
#ifdef VMS
char const_flag = 0;
void s_const();
#endif
#ifdef DONTDEF
void s_gdbline(), s_gdblinetab();
void s_gdbbeg(), s_gdbblock(), s_gdbend(), s_gdbsym();
#endif
void stringer();
void cons();
void float_cons();
void big_cons();
void stab();
static const pseudo_typeS
potable[] =
{
{ "abort", s_abort, 0 },
{ "align", s_align, 0 },
{ "ascii", stringer, 0 },
{ "asciz", stringer, 1 },
{ "byte", cons, 1 },
{ "comm", s_comm, 0 },
#ifdef VMS
{ "const", s_const, 0 },
#endif
{ "data", s_data, 0 },
{ "desc", s_desc, 0 },
{ "double", float_cons, 'd' },
{ "file", s_file, 0 },
{ "fill", s_fill, 0 },
{ "float", float_cons, 'f' },
#ifdef DONTDEF
{ "gdbbeg", s_gdbbeg, 0 },
{ "gdbblock", s_gdbblock, 0 },
{ "gdbend", s_gdbend, 0 },
{ "gdbsym", s_gdbsym, 0 },
{ "gdbline", s_gdbline, 0 },
{ "gdblinetab",s_gdblinetab, 0 },
#endif
{ "globl", s_globl, 0 },
{ "int", cons, 4 },
{ "lcomm", s_lcomm, 0 },
{ "line", s_line, 0 },
{ "long", cons, 4 },
{ "lsym", s_lsym, 0 },
{ "octa", big_cons, 16 },
{ "org", s_org, 0 },
{ "quad", big_cons, 8 },
{ "set", s_set, 0 },
{ "short", cons, 2 },
{ "single", float_cons, 'f' },
{ "space", s_space, 0 },
{ "stabd", stab, 'd' },
{ "stabn", stab, 'n' },
{ "stabs", stab, 's' },
{ "text", s_text, 0 },
#ifndef SPARC
{ "word", cons, 2 },
#endif
{ NULL} /* end sentinel */
};
static void
pobegin()
{
char * errtxt; /* error text */
const pseudo_typeS * pop;
po_hash = hash_new();
errtxt = ""; /* OK so far */
for (pop=potable; pop->poc_name && !*errtxt; pop++)
{
errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop);
}
for(pop=md_pseudo_table; pop->poc_name && !*errtxt; pop++)
errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop);
if (*errtxt)
{
as_fatal ("error constructing pseudo-op table");
}
} /* pobegin() */
/* read_a_source_file()
*
* File has already been opened, and will be closed by our caller.
*
* We read the file, putting things into a web that
* represents what we have been reading.
*/
void
read_a_source_file (buffer)
char * buffer; /* 1st character of each buffer of lines is here. */
{
register char c;
register char * s; /* string of symbol, '\0' appended */
register int temp;
/* register struct frag * fragP; JF unused */ /* a frag we just made */
pseudo_typeS *pop;
#ifdef DONTDEF
void gdb_block_beg();
void gdb_block_position();
void gdb_block_end();
void gdb_symbols_fixup()